package com.cloud.service;

import java.util.ArrayList;

import com.cloud.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap;

import com.cloud.bean.Bill;
import com.cloud.bean.BillDetail;
import com.cloud.mapper.BillMapper;

import javax.annotation.Resource;

@Service
public class BillService {
	
	@Resource
	private BillMapper billMapper;

	public void selectList(Integer page,ModelMap mode) {
		ArrayList<Bill> list = billMapper.selectList();
		String[] arr = {"编号","手机号","提现金额","余额","提现时间","支付宝","审核状态"};
		mode.addAttribute("list", list);
		mode.addAttribute("arr", arr);
	}

	public R updateBillStatus(Bill bill) {
		billMapper.updateBillByStatus(bill);
		return new R(0,"审批成功",null);
	}

	public void selectFlushList(Integer page,Integer value, ModelMap mode) {
		Integer status = 2;
		ArrayList<Bill> list;
		String[] arr = {"编号","手机号","提现金额","余额","提现时间","支付宝","审核状态"};
		if(value==0) {
			status = 0;
			list = billMapper.selectListByStatus(status);
		}else if(value==1) {
			status = 1;
			arr = new String[]{"编号","手机号","提现金额","余额","提现时间","支付宝","不通过原因"};
			list = billMapper.selectListByStatus(status);
		}else if(value == 3) {
			list = billMapper.selectList();
		}else {
			list = billMapper.selectListByStatus(status);
		}
		mode.addAttribute("list", list);
		mode.addAttribute("arr", arr);
	}
	
	public R updateReason(Bill bill) {
		billMapper.updateBillByReason(bill);
		return new R(0,"更新成功",null);
	}

	public R seletBillDetail(String order) {
		BillDetail detail = billMapper.selectBillDetail(order);
		return new R(0,"",detail);
	}
}
